<template>
	<view>
		<uni-nav-bar statusBar title="定价" :border='false' color="#000" fixed :backgroundColor='backgroundColor'>
			<block slot="left">
				<image class="logo1" src="/static/common/logo1.png" mode=""></image>
			</block>
			<block slot="right">
				<image class="logo1" src="/static/common/logo2.png" mode=""></image>
			</block>
		</uni-nav-bar>
		<image class="BGImage" :src="getImageUrl('/static/common/BG.png')" mode=""></image>
		<view class="" style="position: relative;z-index: 2;">
		<view class="topView"  @click="buttonClick()">
			<view class="view1">
				<view class="view2 flex-row-space-between">
					<view class="">
						<view class="num flex-row-flex-start">
							853.14
							<uni-icons color="#E52B3B"  type="arrow-up" size="30"></uni-icons>
						</view>
						<view class="time">
							09-24 14:27:25
						</view>
					</view>
					<view class="">
						<view class="num1" style="margin-top: 20rpx;">
							今开: <text style="color:#333333;margin-right: 20rpx;">848.40</text> 
							最高:<text style="color:#333333">848.40</text>
						</view>
						<view class="num1">
							昨开: <text style="color:#E52B3B;margin-right: 20rpx;">848.40</text> 
							最低: <text style="color:#0E9876">848.40</text> 
						</view>
					</view>
				</view>
			</view>
			<view class="flex-row-space-between" style="margin: 24rpx;">
				<image src="/static/common/1.png" mode="" style="width: 342rpx;height: 360rpx;"></image>
				<view class="">
					<image src="/static/common/2.png" mode="" style="width: 344rpx;height: 160rpx;"></image>
					<view class="">
						<image src="/static/common/3.png" mode="" style="width: 164rpx;height: 184rpx;"></image>
						<image src="/static/common/4.png" mode="" style="width: 164rpx;height: 184rpx;margin-left: 20rpx;"></image>
					</view>
				</view>
			</view>
			<view class="" style="margin: 24rpx;" >
				<image src="/static/common/image2.png" mode="widthFix" style="width: 100%;"></image>
			</view>
			<view class="" style="margin: 24rpx;" >
				<image src="/static/common/image1.png" mode="widthFix" style="width: 100%;"></image>
			</view>
			<view class="topView2"  >
				<view class="title">
					回收服务中心
				</view>
			</view>
		</view>
	
			</view>

	</view>
</template>

<script>
		// 图表
		import uCharts from "@/components/u-charts/u-charts.js";
		var _self;
		var canvaRing = null;
		var canvaArea = null;
		var canvaGauge = null;
		var canvaPie = null;
		var canvaColumn = null;
		var canvaFunnel = null;
		var canvaWord = null;
	import {
		mapActions,
		mapState
	} from "vuex";
	import {
		lineList,
	} from '@/api/index.js'
	export default {
		components: {},
		computed: {

		},
		data() {
			return {
				list:[
					'图表目前均使用：《uCharts高性能跨端图表》，小程序如需接入Echarts等其他图表，敬请期待作者更新...'
				],
				cWidth: '',
				cHeight: '',
				pixelRatio: 1,
				// 折线图
				Area: {
					categories: ['6月', '7月', '8月', '9月', '10月', '11月', '12月'],
					series: [{
						name: '',
						data: [100, 80, 95, 150, 112, 132, 151],
						color: '#facc14'
					}]
				},
				keyword:'',
				list: [],
				title: "",
				backgroundColor: 'ffffff00',
				list: [],
				data: {}

			}
		},
		computed: {
			...mapState([
				'baseColor'
			]),
		},
		onPageScroll(e) {
			if (e.scrollTop > 20) {
				this.backgroundColor = "#BBD8F6"
			} else {
				this.backgroundColor = "#ffffff00"
			}
		},
		onShow() {
			// this.loadData()
			_self = this;
			this.cWidth = uni.upx2px(750);
			this.cHeight = uni.upx2px(420);
			this.getServerData();
		},
		onLoad(e) {
			
		},
		//下拉刷新
		onPullDownRefresh() {


		},
		//加载更多
		onReachBottom() {

		},
		onPageScroll(e) {
			// if (e.scrollTop > 20) {
			// 	this.backgroundColor = "#FBF9FF"
			// } else {
			// 	this.backgroundColor = "#ffffff00"
			// }
		},
		methods: {
			buttonClick(){
				this.toUrl('buy')
				// this.showToast('请先实名')
			},
			getServerData() {
				_self.showArea("canvasArea", this.chartData);
				_self.showRadar("canvasRadar", this.chartData);
				_self.showRing("canvasRing", this.Ring);
				_self.showGauge("canvasGauge", this.Gauge);
				_self.showPie("canvasPie", this.Pie);
				_self.showColumn("canvasColumn", this.Column);
				_self.showFunnel("canvasFunnel", this.Column);
				_self.showData("canvasData", this.Data);
			},
			
			// 词云图
			showData(canvasId, chartData) {
				canvaWord = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'word',
					background: '#ffffff',
					pixelRatio: _self.pixelRatio,
					series: _self.cyData.series,
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					extra: {
						word: {
							type: 'normal'
						}
					}
				});
			},
			
			
			// 漏斗图
			showFunnel(canvasId, chartData) {
				canvaFunnel = new uCharts({
					$this: this,
					canvasId: canvasId,
					type: 'funnel',
					fontSize: 11,
					// padding: [15, 15, 0, 15],
					legend: {
						show: true,
						padding: 5,
						lineHeight: 11,
						margin: 0,
					},
					background: '#FFFFFF',
					pixelRatio: this.pixelRatio,
					series: this.Funnel.series,
					animation: true,
					width: this.cWidth * this.pixelRatio,
					height: this.cHeight * this.pixelRatio,
					dataLabel: true,
					extra: {
						funnel: {
							border: true,
							borderWidth: 2,
							borderColor: '#FFFFFF'
						}
					},
				})
			},
			// 柱状图
			showColumn(canvasId, chartData) {
				canvaColumn = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'column',
					legend: true,
					fontSize: 11,
					background: '#FFFFFF',
					pixelRatio: _self.pixelRatio,
					animation: true,
					categories: _self.Column.categories,
					series: _self.Column.series,
					xAxis: {
						disableGrid: true,
					},
					yAxis: {
						//disabled:true
					},
					dataLabel: true,
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					extra: {
						column: {
							type: 'group',
							width: _self.cWidth * _self.pixelRatio * 0.45 / _self.Column.categories.length
						}
					}
				});
			},
			touchColumn(e) {
				canvaColumn.showToolTip(e, {
					format: function(item, category) {
						if (typeof item.data === 'object') {
							return category + ' ' + item.name + ':' + item.data.value
						} else {
							return category + ' ' + item.name + ':' + item.data
						}
					}
				});
			},
			
			// 仪表盘
			showGauge(canvasId, chartData) {
				canvaGauge = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'gauge',
					fontSize: 11,
					legend: false,
					title: {
						name: Math.round(_self.chartData.series[0].data * 100) + '%',
						color: _self.chartData.categories[1].color,
						fontSize: 25 * _self.pixelRatio,
						offsetY: 50 * _self.pixelRatio, //新增参数，自定义调整Y轴文案距离
					},
					subtitle: {
						name: _self.chartData.series[0].name,
						color: '#666666',
						fontSize: 15 * _self.pixelRatio,
						offsetY: -50 * _self.pixelRatio, //新增参数，自定义调整Y轴文案距离
					},
					extra: {
						gauge: {
							type: 'default',
							width: _self.gaugeWidth * _self.pixelRatio, //仪表盘背景的宽度
							startAngle: 0.75,
							endAngle: 0.25,
							startNumber: 0,
							endNumber: 100,
							splitLine: {
								fixRadius: 0,
								splitNumber: 10,
								width: _self.gaugeWidth * _self.pixelRatio, //仪表盘背景的宽度
								color: '#FFFFFF',
								childNumber: 5,
								childWidth: _self.gaugeWidth * 0.4 * _self.pixelRatio, //仪表盘背景的宽度
							},
							pointer: {
								width: _self.gaugeWidth * 0.8 * _self.pixelRatio, //指针宽度
								color: 'auto'
							}
						}
					},
					background: '#FFFFFF',
					pixelRatio: _self.pixelRatio,
					categories: _self.chartData.categories,
					series: _self.chartData.series,
					animation: true,
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					dataLabel: true,
				});
			},
			
			// 圆环图
			showRing(canvasId, chartData) {
				canvaRing = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'ring',
					fontSize: 11,
					legend: true,
					extra: {
						pie: {
							offsetAngle: -45,
							ringWidth: 30 * _self.pixelRatio,
							lableWidth: 15
						}
					},
					background: '#FFFFFF',
					pixelRatio: _self.pixelRatio,
					series: _self.Ring.series,
					animation: true,
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					disablePieStroke: true,
					dataLabel: true,
				});
			},
			touchRing(e) {
				canvaRing.showToolTip(e, {
					format: function(item) {
						return item.name + ':' + item.data
					}
				});
			},
			
			// 饼状图
			showPie(canvasId, chartData) {
				canvaPie = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'pie',
					fontSize: 11,
					legend: true,
					background: '#FFFFFF',
					pixelRatio: _self.pixelRatio,
					series: _self.Pie.series,
					animation: true,
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					dataLabel: true,
					extra: {
						pie: {
							lableWidth: 15
						}
					},
				});
			},
			touchPie(e) {
				canvaPie.showToolTip(e, {
					format: function(item) {
						return item.name + ':' + item.data
					}
				});
			},
			
			// 折线图
			showArea(canvasId, chartData) {
				canvaArea = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'area',
					fontSize: 11,
					legend: true,
					dataLabel: false,
					dataPointShape: true,
					background: '#FFFFFF',
					pixelRatio: _self.pixelRatio,
					categories: _self.Area.categories,
					series: _self.Area.series,
					animation: true,
					xAxis: {
						type: 'grid',
						gridColor: '#CCCCCC',
						gridType: 'dash',
						dashLength: 8
					},
					yAxis: {
						gridType: 'dash',
						gridColor: '#CCCCCC',
						dashLength: 8,
						splitNumber: 5,
						min: 10,
						max: 180,
					},
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					extra: {
						area: {
							type: 'straight',
							opacity: 0.2,
							addLine: true,
							width: 2
						}
					}
				});
			},
			touchArea(e) {
				canvaArea.showToolTip(e, {
					format: function(item, category) {
						return item.name + ' ' + category + ' ' + ':' + item.data
					}
				});
			},
			
			// 雷达图
			showRadar(canvasId, chartData) {
				var canvaRadar = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'radar',
					fontSize: 11,
					padding: [40, 15, 30, 15],
					legend: {
						show: false
					},
					colors: ['#14bcff'],
					background: '#FFFFFF',
					pixelRatio: _self.pixelRatio,
					animation: true,
					dataLabel: true,
					categories: _self.radar.categories,
					series: _self.radar.series,
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					extra: {
						radar: {
							max: 100, //雷达数值的最大值
							opacity: 0.6,
							labelColor: '#333333'
						}
					}
				});
			},


		}
	}
</script>

<style lang="scss">
	.view1{
		margin: 24rpx;
		margin-top: 40rpx;
		height: 566rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	.view2{
		padding: 0 24rpx;
		height: 160rpx;
		background: linear-gradient( 180deg, #FEEFE0 0%, #FFFFFF 100%);
		border-radius: 16rpx 16rpx 0rpx 0rpx;
		// border: 2rpx solid #FFFFFF;
	}
	.num{
		font-weight: 800;
		font-size: 56rpx;
		color: #E52B3B;
	}
	.time{
		font-weight: 400;
		font-size: 24rpx;
		color: #666666;
	}
	.num1{
		font-weight: 500;
		font-size: 26rpx;
		color: #999999;
	}
	.topView2{
		margin: 24rpx;
		padding: 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	.title{
		font-weight: bold;
		font-size: 32rpx;
		color: #333333;
	}
</style>